package slave;
import java.util.concurrent.PriorityBlockingQueue;

/**
 * Classe Singleton utilizzata per la gestione delle porte utilizzabili
 * nella trasmissione bluetooth.
 * @author alex
 *
 */
public class BluetoothClientPortContainer {

	  private static BluetoothClientPortContainer instance;
	  private PriorityBlockingQueue<String> clientsPorts;

	  private BluetoothClientPortContainer(){
			clientsPorts = new PriorityBlockingQueue<String>();  
	  }

	  public static BluetoothClientPortContainer getInstance(){
	    if (instance == null){
	      instance = new BluetoothClientPortContainer();
	    }
	    return instance;
	  }
	  
	  public void addPort(String port){
		  clientsPorts.add(port);
	  }
	  
	  public boolean checkPort(String port){
		  boolean free = clientsPorts.contains(port);
		  return free;
	  }
	  
	  public int getNumber(){
		  return clientsPorts.size();
	  }
	  
	  public void removePort(String port){
		  clientsPorts.remove(port);
	  }
	  
	  public void removeAll(){
		  clientsPorts.clear();
	  }
	  
	}


	

